import time
import jwt
def create_jwt(username,uid):
    payload = {
        "iss": "gusibi.com",
        "iat": int(time.time()),
        "exp": int(time.time()) + 86400 * 7,
        "aud": "nishidashazi",  # 谁颁发的
        "username": username,  # 用户名字
        "uid": uid,  # 用户的唯一表示
        "scopes": ['open']  # 那个平台认可
    }
    token = jwt.encode(payload, 'secret', algorithm='HS256')
    return token.decode("utf-8")



def verify_jwt(token):
    payload = jwt.decode(token, 'secret', audience='nishidashazi', algorithms=['HS256'])#解码
    print("验证token",payload.get("uid"))
    return payload.get("uid")
